package wgy.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import wgy.response.Result;
import wgy.system.entity.User;
import wgy.system.service.UserService;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author wanggy
 * @since 2021-12-15
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/findUserList")
    public Result findUserList(@RequestParam(required = true,defaultValue = "1")Integer current,
                               @RequestParam(required = true,defaultValue = "7")Integer size){
        //对用户进行分页
        Page<User> userPage = new Page<>(current,size);
        Page<User> page = userService.page(userPage);
        long total = page.getTotal();
        List<User> userList = page.getRecords();

        return Result.ok().data("total",total).data("records",userList);
    }
}
